class Equipado{
  final int equipmentsTypes = 6;
  ArrayList Equipped = new ArrayList();
  
  Head H;
  Armor A;
  Weapon W;
  Shield S;
  Legs L;
  Feet F;
  
  void toEquip(Equipamento E){
    switch (E.getSlot()){
      case 0 : //Head
        if (H != null){
          toUnEquip(E); 
          H = (Head) E;
        } else H = (Head) E; 
        break;
      case 1 : //Armor
        if (A != null){
          toUnEquip(E); 
          A = (Armor) E;
        } else A = (Armor) E; 
        break;
      case 2 : //Weapon
        if (S != null && ((Weapon) E).getTwoHanded()) return;
        if (W != null){
          toUnEquip(E); 
          W = (Weapon) E;
        } else W = (Weapon) E; 
        break;
      case 3 : //Shield
        if (W != null && W.getTwoHanded()) return;
        if (S != null){
            toUnEquip(E); 
            S = (Shield) E;
          } else S = (Shield) E; 
        break;
      case 4 : //Legs
        if (L != null){
          toUnEquip(E); 
          L = (Legs) E;
        } else L = (Legs) E; 
        break;
      case 5 : //Feet
        if (F != null){
          toUnEquip(E); 
          F = (Feet) E;
        } else F = (Feet) E; 
        break;
    }
    Equipped.add(E);    
  }

  void toUnEquip(Equipamento E){
    if (!(Equipped.contains(E)))
      return;
    switch (E.getSlot()){
      case 0 : H = null; break;
      case 1 : A = null; break;
      case 2 : W = null; break;
      case 3 : S = null; break;
      case 4 : L = null; break;
      case 5 : F = null; break;
    }
    Equipped.remove(Equipped.indexOf(E));    
  }

  int getTotalDefense(){
    int d = 0;
    for (Object aux : Equipped) d += ((Equipamento) aux).def;
    return d;
  }
  float getWeight(int x){
    switch (x){
      case head : (H != null) ? return H.getWeight() : 0;
      case armor : (A != null) ? return A.getWeight() : 0;
      case weapon : (W != null) ? return W.getWeight() : 0;
      case shield : (S != null) ? return S.getWeight() : 0;
      case legs : (L != null) ? return L.getWeight() : 0;
      case foot : (F != null) ? return F.getWeight() : 0;
    }
  }
  int getAtk(){return W != null ? W.getAtk() : 0;}
  int getWClass(){return W!= null ? W.getWClass() : fist;}
}
